const webpack = require('webpack');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');

module.exports = {
	/*
	 ** Headers of the page
	 */
	//offline: true,
	head: {
		titleTemplate: 'CRM - %s',
		meta: [{
				charset: 'utf-8',
			}, {
				name: 'viewport',
				content: 'width=device-width, initial-scale=1'
			}, {
				hid: 'description',
				content: "CRM project"
			},
			// {
			//     HTTP-EQUIV:'pragma',
			//     CONTENT:'no-cache'
			// },
			// {
			//    HTTP-EQUIV:'Cache-Control',
			//     CONTENT:'no-cache, must-revalidate' 
			// },
			// {
			//     HTTP-EQUIV:'expires',
			//     CONTENT:'0'
			// }

		],
		link: [{
			rel: 'icon',
			type: 'image/x-icon',
			href: '/favicon.ico'
		}]
	},
	router: {
		base: '/'
	},
	/*
	 ** Global CSS
	 */
	css: [
		'~assets/css/main.css',
		'element-ui/lib/theme-chalk/index.css',
		'font-awesome/css/font-awesome.css'
	],
	build: {
		filenames: {
			manifest: 'manifest.[hash].js',
			css: 'app.[hash].css', // default: style.css
			vendor: 'vendor.[hash].js', // default: vendor.bundle.js
			app: 'app.[chunkhash].js' // default: nuxt.bundle.js
		},
		vendor: ['~plugins/axios.js', 'babel-polyfill','vue2-editor'],
		babel: {
			"presets": ["es2015", "stage-2"],
			"plugins": [
				"transform-runtime", ["component", [{
					"libraryName": "element-ui",
					//"styleLibraryName": "theme-chalk"
				}]],

				["transform-vue-jsx"],
			],
			"comments": false

		},
		loaders: [{
				test: /\.css$/,
				loader: 'vue-style-loader!css-loader'
			},

			{
				test: /\.(png|jpe?g|gif|svg)$/,
				loader: 'url-loader',
				query: {
					limit: 1000, // 1KO
					name: 'img/[name].[hash:7].[ext]'
				}
			}, {
				test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
				loader: 'url-loader',
				query: {
					limit: 1000, // 1 KO
					name: 'fonts/[name].[hash:7].[ext]'
				}
			}
		],
		postcss: [
			require('autoprefixer')({
				browsers: ['last 3 versions']
			})
		],
		//build
        plugins: [
			new webpack.optimize.DedupePlugin(),
			//TODO build 时使用
            /*new webpack.optimize.LimitChunkCountPlugin({maxChunks: 30}),
            new webpack.optimize.MinChunkSizePlugin({minChunkSize: 50000}),
			new webpack.NoEmitOnErrorsPlugin(),
            new ParallelUglifyPlugin({
                sourceMap: true,
                uglifyJS:{
                    output: {
                        comments: false
                    },
                    compress: {
                        warnings: false
                    }
                }
            }),*/
		    new webpack.optimize.AggressiveMergingPlugin()
        ],
        //TODO 正式环境
        //publicPath: '//crm-loon.oss-cn-hangzhou.aliyuncs.com/nuxt/',
	},

	plugins: [
	    { src: '~plugins/vue2-edit', ssr: false }
	],
    //plugins: ['~plugins/axios.js'],
    loading: {
        color: '#3B8070'
    },
    env: {
//      baseUrl:'http://192.168.1.7:8088',
        // baseUrl:'http://192.168.61.150:8088',
        // baseUrl:'http://120.55.13.136:8088',
		// baseUrl: 'http://192.168.61.92:8088',
        // baseUrl: 'http://www.loonscrm.cn:58231/api',
          baseUrl: '/api',
    },
    generate: {
        routes: [
            '/power/user-control/add',
            '/power/user-control/edit'
        ]
    }
};